package com.atguigu.flink.chapter02_DataStreamAPI.source;

import com.alibaba.fastjson.JSON;
import com.atguigu.flink.pojo.MarketingUserBehavior;
import org.apache.commons.lang3.RandomUtils;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;
import org.apache.flink.streaming.api.functions.source.SourceFunction;

/**
 * Created by Smexy on 2022/10/21
 *
 *  模拟一个Source，会每隔500ms，产生
 *      一条:
 *          behavior: install,uninstall,download,update
 *          channel:  ZTE,APPLE,HUAWEI,MI,VIVO,OPPO
 *              { userId:100,behavior:"uninstall","channel":"ZTE",timestamp:xxx  }
 *
 *   实现 SourceFunction，源源不断地获取数据
 */
public class Demo3_CustomSource
{
    public static void main(String[] args) {
        
        StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
        
        //新建自定义的数据源对象
        MySource mySource = new MySource();
        env.addSource(mySource)
           .print();

        try {
                    env.execute();
                } catch (Exception e) {
                    e.printStackTrace();
                }
        
    }


}
